<template>
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"

        @change="handleTableChange">

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <stmChannelProduct-modal ref="modalForm" @ok="modalFormOk"></stmChannelProduct-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import StmChannelProductModal from './modules/StmChannelProductModal'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getAction} from "@api/manage";

export default {
  name: "StmChannelProductList",
  mixins: [JeecgListMixin],
  components: {
    StmChannelProductModal
  },
  data() {
    return {
      description: '渠道产品表管理页面',
      // 表头
      columns: [
        {
          title: '商品名称',
          align: "center",
          dataIndex: 'productName'
        },
        {
          title: '物料编码',
          align: "center",
          dataIndex: 'skuCode'
        },
        {
          title: '价格',
          align: "center",
          dataIndex: 'price'
        },
        {
          title: '状态',
          align: "center",
          dataIndex: 'status_dictText'
        }
      ],
      url: {
        list: "/stm/stmChannelPrice/list",
        delete: "/stm/stmChannelProduct/delete",
        deleteBatch: "/stm/stmChannelProduct/deleteBatch",
        exportXlsUrl: "stm/stmChannelProduct/exportXls",
        importExcelUrl: "stm/stmChannelProduct/importExcel",
      },
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    loadData(arg) {
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams();
      if(params.channelId==null && params.stroreId==null){
        return;
      }
      getAction(this.url.list, {
        channelId: params.channelId,
        storeId:params.stroreId,
        pageNo: this.ipagination.current, pageSize: this.ipagination.pageSize
      }).then((res) => {
        if (res.success) {
          console.log("jjjjj")
          this.dataSource = res.result.records
          this.ipagination.total = res.result.total
        } else {
          console.log("lllll")
          this.dataSource = null
        }
      })
    },
    getMain(channelId,storeId) {
      this.queryParam.channelId = channelId
      this.queryParam.stroreId = storeId
      this.loadData(1)
    },
    clear(){
        this.queryParam.channelId = null
      this.queryParam.stroreId = null
      this.ipagination.current = 1
      this.dataSource = null

    }
  }
}
</script>
<style scoped>
.ant-card {
  margin-left: -24px;
  margin-right: -24px;
}
</style>